package com.bqtv.sport.ui.match.fragment

import android.os.Bundle
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.viewbinding.ViewBinding
import com.bqtv.sport.R
import com.bqtv.sport.adapter.MatchDetailAdapter
import com.bqtv.sport.app.AppActivity
import com.bqtv.sport.app.AppFragment
import com.bqtv.sport.databinding.FragmentMatchFollowBinding
import com.bqtv.sport.event.MatchFragmentEvent
import org.greenrobot.eventbus.EventBus


class MatchFollowFragment : AppFragment<FragmentMatchFollowBinding, AppActivity<ViewBinding>>() {
    private lateinit var detailAdapter: MatchDetailAdapter

    companion object {
        private const val INTENT_KEY_TYPE = "type"
        fun newInstance(): MatchFollowFragment {
            val fragment = MatchFollowFragment()
            val bundle = Bundle()
            fragment.arguments = bundle
            return fragment
        }

        fun newInstance(type: String?): MatchFollowFragment {
            val fragment = MatchFollowFragment()
            val bundle = Bundle()
            bundle.putString(INTENT_KEY_TYPE, type)
            fragment.arguments = bundle
            return fragment
        }
    }

    override fun getViewBinding() = FragmentMatchFollowBinding.inflate(layoutInflater)

    override fun initView() {
//        binding.llNoData.visibility = View.GONE
//        binding.rcvMatch.visibility = View.VISIBLE

        binding.rcvMatch.layoutManager=LinearLayoutManager(requireContext())
        detailAdapter= MatchDetailAdapter()
        binding.rcvMatch.adapter=detailAdapter
    }

    override fun initData() {
        var list = arrayListOf<String>("全部", "推荐", "关注", "视频", "图片", "直播")
        detailAdapter.submitList(list)

        initListener()
    }
    private fun initListener() {
        binding.tvFollow.setOnClickListener(this)
    }
    override fun onClick(v: View) {
        when (v.id) {
            R.id.tv_follow -> {
                EventBus.getDefault().post(MatchFragmentEvent(1))
            }
        }
    }
}

